package com.jianbing.north.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jianbing.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jianbing.common.annotation.Log;
import com.jianbing.common.core.controller.BaseController;
import com.jianbing.common.core.domain.AjaxResult;
import com.jianbing.common.enums.BusinessType;
import com.jianbing.north.domain.NorthPart1Video;
import com.jianbing.north.service.INorthPart1VideoService;
import com.jianbing.common.utils.poi.ExcelUtil;
import com.jianbing.common.core.page.TableDataInfo;

/**
 * part1视频Controller
 * 
 * @author zjw
 * @date 2024-06-22
 */
@RestController
@RequestMapping("/north/video")
public class NorthPart1VideoController extends BaseController
{
    @Autowired
    private INorthPart1VideoService northPart1VideoService;

    /**
     * 查询part1视频列表
     */
    //  @PreAuthorize("@ss.hasPermi('north:video:list')")
    @GetMapping("/list")
    public TableDataInfo list(NorthPart1Video northPart1Video)
    {
        startPage();
        List<NorthPart1Video> list = northPart1VideoService.selectNorthPart1VideoList(northPart1Video);
        return getDataTable(list);
    }

    /**
     * 导出part1视频列表
     */
    //  @PreAuthorize("@ss.hasPermi('north:video:export')")
    @Log(title = "part1视频", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NorthPart1Video northPart1Video)
    {
        List<NorthPart1Video> list = northPart1VideoService.selectNorthPart1VideoList(northPart1Video);
        ExcelUtil<NorthPart1Video> util = new ExcelUtil<NorthPart1Video>(NorthPart1Video.class);
        util.exportExcel(response, list, "part1视频数据");
    }

    /**
     * 获取part1视频详细信息
     */
    //   @PreAuthorize("@ss.hasPermi('north:video:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(northPart1VideoService.selectNorthPart1VideoById(id));
    }

    /**
     * 新增part1视频
     */
    //   @PreAuthorize("@ss.hasPermi('north:video:add')")
    @Log(title = "part1视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NorthPart1Video northPart1Video)
    {
        return toAjax(northPart1VideoService.insertNorthPart1Video(northPart1Video));
    }

    /**
     * 修改part1视频
     */
    //  @PreAuthorize("@ss.hasPermi('north:video:edit')")
    @Log(title = "part1视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NorthPart1Video northPart1Video)
    {
        return toAjax(northPart1VideoService.updateNorthPart1Video(northPart1Video));
    }

    /**
     * 删除part1视频
     */
    //  @PreAuthorize("@ss.hasPermi('north:video:remove')")
    @Log(title = "part1视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(northPart1VideoService.deleteNorthPart1VideoByIds(ids));
    }

    // @PreAuthorize("@ss.hasPermi('north:stem:query')")
    @GetMapping()
    public AjaxResult getVideo()
    {
        Long userId = SecurityUtils.getUserId();
        return success(northPart1VideoService.selectRandNorthVideoByUserId(userId));
    }
}
